import request from "@/axios/request";
import { defineStore } from "pinia";
import { store } from "./store";

export const useWorkTaskStore = defineStore("workTask", () => {
  function health(params) {
    return request.get({
      url: "/api/Health",
      params: params,
    });
  }
  function createWorkTask(data) {
    return request.post({
      url: "/api/WorkTask/CreateWorkTask",
      data: data,
    });
  }
  function createSimulationWorkTask(data) {
    return request.post({
      url: "/api/WorkTask/CreateSimulationWorkTask",
      data: data,
    });
  }
  function getWorkTask(params) {
    return request.get({
      url: "/api/WorkTask/GetWorkTask",
      params: params,
    });
  }
  function startWorkTask(data) {
    return request.post({
      url: "/api/WorkTask/StartWorkTask",
      data: data,
    });
  }
  function passProve(data) {
    return request.post({
      url: "/api/WorkTask/PassProve",
      data: data,
    });
  }
  function rejectProve(data) {
    return request.post({
      url: "/api/WorkTask/RejectProve",
      data: data,
    });
  }
  function withdrawProve(data) {
    return request.post({
      url: "/api/WorkTask/WithdrawProve",
      data: data,
    });
  }
  function forwardProve(data) {
    return request.post({
      url: "/api/WorkTask/ForwardProve",
      data: data,
    });
  }
  function getAllTaskStepsOfWorkTask(params) {
    return request.get({
      url: "/api/WorkTask/GetAllTaskStepsOfWorkTask",
      params: params,
    });
  }
  function clearSimulationRecord(data) {
    return request.get({
      url: "/api/WorkTask/ClearSimulationRecord",
      data: data,
    });
  }
  function getUnHandledWorkTasksOfUser(params) {
    return request.get({
      url: "/api/WorkTask/GetUnHandledWorkTasksOfUser",
      params: params,
    });
  }
  function getHandledWorkTasksOfUser(params) {
    return request.get({
      url: "/api/WorkTask/GetHandledWorkTasksOfUser",
      params: params,
    });
  }
  function getAllTaskStepsOfWorkTaskByEntityInfo(params) {
    return request.get({
      url: "/api/WorkTask/GetAllTaskStepsOfWorkTaskByEntityInfo",
      params: params,
    });
  }
  function getWorkTasksOfCreator(params) {
    return request.get({
      url: "/api/WorkTask/GetWorkTasksOfCreator",
      params: params,
    });
  }
  function getAllWorkTasks(params) {
    return request.get({
      url: "/api/WorkTask/GetAllWorkTasks",
      params: params,
    });
  }
  function deleteWorkTasks(data) {
    return request.delete({
      url: "/api/WorkTask/deleteWorkTasks",
      data: data,
    });
  }
  function GetAllUserForSimulation(params) {
    return request.get({
      url: "/api/WorkTask/GetAllUserForSimulation",
      params: params,
    });
  }
  function GetRejectNodes(params) {
    return request.get({
      url: "/api/WorkTask/GetRejectNodes",
      params: params,
    });
  }
  function deleteWorkTask(params) {
    return request.delete({
      url: "/api/WorkTask/DeleteWorkTask",
      params: params,
    });
  }
  function updateWorkTaskFormData(data) {
    return request.put({
      url: "/api/WorkTask/UpdateWorkTaskFormData",
      data: data,
    });
  }
 
  function getForecastNodeUsers4Task(params) {
    return request.get({
      url: "/api/WorkTask/GetForecastNodeUsers4Task",
      params: params,
    });
  }
  function getForecastNodeUsers4Workflow(params) {
    return request.post({
      url: "/api/WorkTask/GetForecastNodeUsers4Workflow",
      data: params,
    });
  }

  function getPenddingTaskStepsOfWorkTask(params) {
    return request.get({
      url: "/api/WorkTask/GetPenddingTaskStepsOfWorkTask",
      params: params,
    });
  }

  function createWorkTaskWithDefaultVersion(data) {
    return request.post({
      url: "/api/WorkTask/CreateWorkTaskWithDefaultVersion",
      method: "post",
      data: data,
    });
  }

  function copyWorkTask(data) {
    return request.post({
      url: "/api/WorkTask/CopyWorkTask",
      method: "post",
      data: data,
    });
  }

  function cancelWorkTask(data) {
    return request.put({
      url: "/api/WorkTask/CancelWorkTask",
      method: "put",
      data: data,
    });
  }

  function getWorkTaskByEntityInfo(params) {
    return request.get({
      url: "/api/WorkTask/GetWorkTaskByEntityInfo",
      method: "get",
      params: params,
    });
  }

  return {
    getWorkTask,
    startWorkTask,
    passProve,
    rejectProve,
    withdrawProve,
    forwardProve,
    getAllTaskStepsOfWorkTask,
    clearSimulationRecord,
    getUnHandledWorkTasksOfUser,
    getHandledWorkTasksOfUser,
    getAllTaskStepsOfWorkTaskByEntityInfo,
    getWorkTasksOfCreator,
    getAllWorkTasks,
    deleteWorkTask,
    deleteWorkTasks,
    GetAllUserForSimulation,
    GetRejectNodes,
    updateWorkTaskFormData,
    getForecastNodeUsers4Task,
    getForecastNodeUsers4Workflow,
    createWorkTask,
    createSimulationWorkTask,
    getPenddingTaskStepsOfWorkTask,
    createWorkTaskWithDefaultVersion,
    copyWorkTask,
    cancelWorkTask,
    getWorkTaskByEntityInfo,
  };
});

export const useWorkTaskStoreWithOut = () => {
  return useWorkTaskStore(store);
};
